<?php
namespace app\serverfund\logic;

use \app\manage\logic\BaseLogic;

class CurrencyUnfreezeLog extends BaseLogic
{
    protected $name = 'currency_unfreeze_log';
    protected $config = 'db_config_fund';
    private $currencyUnfreezeLogModel = '\app\serverfund\model\CurrencyUnfreezeLog';

    // 所有用户数字币解冻日志分页数据
    public function list(array $data): array
    {
        $where['status'] = 1;
        $data['keywords'] && $where['user_id'] = ['like', '%' . $data['keywords'] . '%'];
        
        if($data['startTime']){
            $where['create_time'] = $data['endTime'] ? ['between', [$data['startTime'],$data['endTime']]] : ['egt', $data['startTime']];
        }else{
            $data['endTime'] && $where['create_time'] = ['elt', $data['endTime']];
        } 
        $res = $this->model($this->currencyUnfreezeLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->paginate($data['list_rows'], false, ['page'=>$data['page']])
                    ->toArray();
        return auto_return_page($res, '已找到用户数字币解冻日志', '没有用户数字币解冻日志');
    }
    // 获取某些user_ids的的数字币解冻日志(分页)
    public function listByUserIds(array $data): array
    {
        $where['status'] = 1;
        $where['user_id'] = ['IN', $data['user_ids']];
        $res = $this->model($this->currencyUnfreezeLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->paginate($data['list_rows'], false, ['page'=>$data['page']])
                    ->toArray();
        return auto_return_page($res, '已找到用户数字币解冻日志', '没有用户数字币解冻日志');
    }
    // 获取某个冻结日志的数字币解冻日志
    public function listByFreezeId(array $data): array
    {
        $where['status'] = 1;
        $where['freeze_log_id'] = $data['freeze_log_id'];

        $res = $this->model($this->currencyUnfreezeLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->select();
        return auto_return($res, '已找到数字币解冻日志', '没有数字币解冻日志');
    }
}